-
-
Notifications
You must be signed in to change notification settings - Fork 247
[SeongA] WEEK 06 solutions #1863
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
같은 Swift라 넘 반갑네용! 다 푸시다니 넘 대단하십니다👏
var isEndOfWord: Bool = false | ||
} | ||
|
||
var root: TrieNode? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
init일 때 TrieNode()로 넣어주기 때문에 optional일 필요가 없을 것 같아요
} | ||
currentNode = currentNode?.children[char] | ||
if index == word.count - 1 { | ||
currentNode?.isEndOfWord = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
마지막에 해주면 되는 거라서 포문 밖 24라인에 분기 없이 추가해도 됩니답!
if num > lastValue { | ||
tails.append(num) | ||
} else { | ||
if let index = tails.firstIndex(where: { $0 >= num }) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
firstIndex는 O(n)의 함수라 O(logn)인 binarySearch를 구현해보시는 것도 좋을 것 같습니다.
valid-parentheses/delight010.swift
Outdated
let dictionary: [Character: Character] = [")":"(", "]":"[", "}":"{"] | ||
var stack: [Character] = [] | ||
for char in s { | ||
if let closeBucket = dictionary[char] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
네이밍이 closeBucket이 아니라 openBucket이어야 할 것 같습니다
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
지현님, 이해하기 쉽고 상세한 피드백들 너무 감사드립니다!!
답안 제출 문제
작성자 체크 리스트
In Review
로 설정해주세요.검토자 체크 리스트
Important
본인 답안 제출 뿐만 아니라 다른 분 PR 하나 이상을 반드시 검토를 해주셔야 합니다!